package com.liukunup.judge.impl;

import com.liukunup.bean.Rect;
import com.liukunup.distance.IoU;
import lombok.extern.slf4j.Slf4j;
import org.testng.Assert;
import org.testng.Reporter;

/**
 * 交并比判定器
 * @author Liu Kun
 * @date 2021-04-03 20:26:05
 **/
@Slf4j
public class JudgeIoU extends BaseJudge<Rect<Double>> {

    @Override
    public void doJudge(Rect<Double> result, Object reference, Class<?> clazzOfT) {
        Rect<Double> refRect = (Rect<Double>) clazzOfT.cast(reference);
        double iouScore = IoU.calc(result, refRect);
        Reporter.log("IoU: " + iouScore);
        Assert.assertTrue(iouScore > 0, "两矩形框不相交.");
    }
}